﻿using DataSetMerge.DataTableOperators;
using DataSetMerge.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using XmlMerge.Interfaces;

namespace DataSetMerge.Mergers
{
    public class WixHarvestMerger : IMerger<XElement>
    {
        IXmlOperator op;

        public WixHarvestMerger() : this(new WixXmlTableOperator()) { }

        public WixHarvestMerger(IXmlOperator op)
        {
            this.op = op;
        }
    
        public void MergeData(XElement target, XElement source)
        {
            op.RemoveSubtractedEntries(target, source);
 	        op.RemoveDuplicateEntries(source, target);
            op.RemoveChildlessEntries(source);
            op.AddNewEntries(target, source);
            op.RemoveChildlessEntries(target);
        }
    }
}
